﻿using Credera.Theta.API;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Credera.Theta.Modules.Core.Commands
{
    [Command("Clear")]
    [Alias("cls")]
    [Synopsis("Clears the console")]
    class ClearCommand : InputCommand
    {
        public override void Invoke(CommandInvocationContext context)
        {
            if (base.Host is Credera.Theta.Host.WindowsForms.HostInterface)
                this.ClearWindowsFormsHost((Credera.Theta.Host.WindowsForms.HostInterface)base.Host);
        }

        private void ClearWindowsFormsHost(Host.WindowsForms.HostInterface hostInterface)
        {
            if (hostInterface.InvokeRequired)
                hostInterface.BeginInvoke((MethodInvoker)delegate { this.ClearWindowsFormsHost(hostInterface); });
            else
                hostInterface.RTB.Text = string.Empty;
        }

        
    }
}
